<%
# this partial expects:
# +project+ - the current project
# +issue+ - the current issue
#
# notes: don't delete the upload_frame, this is the only way to upload files
# using ajax
comment ||= Comment.new
%>

<div id="comment_form">
  <h2>Add an Update</h2>
  <% form_for comment, :url => comments_path( project.name, issue.local_id,
                              :format => 'js' ),
                              :html => {
                                  :multipart => true,
                                  :target => 'upload_frame'
                                } do |form| -%>
    <%= form.error_messages %>
    <dl>
      <dt><%= form.label :summary, 'Summary', :class => 'required' %></dt>
      <dd><%= form.text_field :summary %></dd>
      <dt><%= form.label :details %></dt>
      <dd><%= form.text_area :details %></dd>
      <dt><%= form.label :status %></dt>
      <dd>
        <%= text_field :issue, :status, :class => 'status', :value =>
                       ( issue.status ? issue.status.name : '' ) %>
        <div id="status_choices" class="autocomplete"></div>
        <%= auto_complete_field 'issue_status',
              :url => autocomplete_status_url,
              :update => 'status_choices',
              :param_name => 'match' %>
        <small>(updates the <em>issue's</em> status)</small>
      </dd>
      <dt><%= form.label :priority %></dt>
      <dd>
        <%= text_field :issue, :priority, :class => 'priority', :value =>
                      ( issue.priority ? issue.priority.name : '' ) %>
        <div id="priority_choices" class="autocomplete"></div>
        <%= auto_complete_field 'issue_priority',
              :url => autocomplete_priority_url,
              :update => 'priority_choices',
              :param_name => 'match' %>
        <small>(updates the <em>issue's</em> priority)</small>
      </dd>
      <dt><%= form.label :tag_list, 'Add Tags' %></dt>
      <dd><%= text_field :issue, :tag_list, :value => issue.tag_list.to_s %></dd>
    </dl>
    <%= render :partial => 'shared/edit_attachments',
               :locals => { :attachments => comment.attachments } %>
    <%= form.submit 'Post Update', :class => 'submit' %>
    <small>Items in <b>bold</b> are required.</small>
  <% end -%>
</div>
<iframe id="upload_frame" name="upload_frame" style="display: none"></iframe>
